//
//  DataLoader.h
//  YonseiApp
//
//  Created by Hyunwoo on 5/31/10.
//  Copyright 2010 YUTAR. All rights reserved.
//

#import <Foundation/Foundation.h>

@class DataLoader;

@protocol DataLoaderDelegate <NSObject>
- (void)dataLoader:(DataLoader *)loader didFinishWithData:(NSMutableData *)data tag:(NSString *)tag;

@optional
- (void)dataLoader:(DataLoader *)loader didFailWithStatusCode:(NSInteger)statusCode reason:(NSString *)reason;

@end


@interface DataLoader : NSURLConnection {
@private    
    NSMutableData *activeDownload;
    BOOL isLoading;
    NSInteger statusCode;
    
    UIActivityIndicatorView *spinner;
}

@property (nonatomic, retain) NSString *tag;
@property (nonatomic, retain) id<DataLoaderDelegate> delegate;

- (id)initWithTag:(NSString *)tag
              url:(NSString *)url
         delegate:(id<DataLoaderDelegate>)delegate;

- (id)initWithTag:(NSString *)tag
              url:(NSString *)url
         delegate:(id<DataLoaderDelegate>)delegate
        superView:(UIView *)superView;

- (id)initWithTag:(NSString *)tag
              url:(NSString *)url
         postData:(NSData *)postData
         delegate:(id <DataLoaderDelegate>)Delegate
        superView:(UIView *)superView;

- (BOOL)isLoading;

- (void)cancel;

@end
